using System;
using System.Xml.Serialization;

namespace Communication
{
    /// <summary>
    /// Represents a phonebook entry.
    /// </summary>
    [Serializable, XmlInclude(typeof(PhonebookEntryWithStorage))]
    public class PhonebookEntry
    {
        private int _index;
        private string _number;
        private string _text;
        private int _type;

        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public PhonebookEntry()
        {
        }

        /// <summary>
        /// Initializes a new instance of the class to copy an existing PhonebookEntry.
        /// </summary>
        /// <param name="entry">The entry to copy.</param>
        public PhonebookEntry(PhonebookEntry entry)
        {
            _index = entry.Index;
            _number = entry.Number;
            _type = entry.Type;
            _text = entry.Text;
        }

        /// <summary>
        /// Initializes a new instance of the class using the specified values.
        /// </summary>
        /// <param name="index">The index where the entry is saved in the phone.</param>
        /// <param name="number">The phone number.</param>
        /// <param name="type">The PhonebookEntry.Number's address type.</param>
        /// <param name="text">The text (name) associated with the PhonebookEntry.Number.</param>
        public PhonebookEntry(int index, string number, int type, string text)
        {
            _index = index;
            _number = number;
            _type = type;
            _text = text;
        }

        /// <summary>
        /// The index where the entry is saved in the phone.
        /// </summary>
        [XmlAttribute]
        public int Index
        {
            get { return _index; }
            set { _index = value; }
        }

        /// <summary>
        /// The phone number.
        /// </summary>
        [XmlAttribute]
        public string Number
        {
            get { return _number; }
            set { _number = value; }
        }

        /// <summary>
        /// The text (name) associated with the PhonebookEntry.Number.
        /// </summary>
        [XmlAttribute]
        public string Text
        {
            get { return _text; }
            set { _text = value; }
        }

        /// <summary>
        /// The PhonebookEntry.Number's address type.
        /// </summary>
        [XmlAttribute]
        public int Type
        {
            get { return _type; }
            set { _type = value; }
        }
    }
}